package com.example.testdemo.trigonView;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by MrYan on 2018/8/30.
 * 三角形View（做气泡用的）
 */

public class TriangleView extends View{
    private Paint mPaint;
    private Path mPath;
    public TriangleView(Context context) {
        super(context);

    }

    public TriangleView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        mPaint = new Paint();
        mPaint.setColor(Color.BLACK);
        mPaint.setAntiAlias(true);
        mPath = new Path();

    }

    public TriangleView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        mPath.moveTo(0,0);
        mPath.lineTo(getWidth()/2,getHeight());
        mPath.lineTo(getWidth(),0);
        mPath.close();
        canvas.drawPath(mPath,mPaint);
    }
}
